package com.atom.wifiupload;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.FrameLayout;

import com.atom.wifiupload.widget.DragLayoutForDoubleView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {


    @BindView(R.id.top_serverlink_layout)
    FrameLayout mTopServerlinkLayout;
    @BindView(R.id.bottom_booklist_layout)
    FrameLayout mBottomBooklistLayout;
    @BindView(R.id.root_view)
    DragLayoutForDoubleView mRootView;

    private ServerLinkFragment mServerLinkFragment;
    private BookListFragment mBookListFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        mServerLinkFragment = new ServerLinkFragment();
        mBookListFragment = new BookListFragment();

        getSupportFragmentManager().beginTransaction()
                .add(R.id.top_serverlink_layout, mServerLinkFragment).add(R.id.bottom_booklist_layout, mBookListFragment)
                .commit();

        DragLayoutForDoubleView.ShowNextPageNotifier nextIntf = new DragLayoutForDoubleView.ShowNextPageNotifier() {
            @Override
            public void onDragNext(int pageIndex) {
                if (pageIndex == 0) {

                } else {
                    mBookListFragment.getDataWithDb();
                }
            }
        };
        mRootView.setNextPageListener(nextIntf);
    }
}
